#ifndef MSPERFORMANCE_H
#define MSPERFORMANCE_H
#include <sys/resource.h>
#include <libmscommon/msnetwork.h>
#include <libmscommon/msmd.h>
#define MS_U64 unsigned long long
typedef struct{	//KByte
	ms_u32 total;
	ms_u32 free;
	ms_u32 shared;
	ms_u32 buff;
	ms_u32 cache;
	ms_u32 available;
	ms_u32 swaptotal;
	ms_u32 swapfree;
}MEMInfo;

#define MAX_NUM_CPU			128
typedef struct{
	ms_byte vgainfo[128];
	ms_byte num_sata;
	ms_byte satainfo[msnet_maxnum_diskdev][128];
	ms_byte satasizeinfo[msnet_maxnum_diskdev][128];
	ms_byte num_SCSIstorage;
	ms_byte SCSIstorageinfo[msnet_maxnum_diskdev][128];
	ms_byte meminfo[128];
	ms_byte audioinfo[128];
	ms_byte num_ethnet;
	ms_byte ethnetinfo[msnet_maxnum_iface][128];
	ms_byte sdhostinfo[128];
	ms_byte num_net;
	ms_byte netinfo[msnet_maxnum_iface][128];
	ms_byte serialbusinfo[128];
}PCIDEVInfo;
typedef struct{
	ms_bool  isinit;
	ms_u08   num;
	ms_u08   ppp_num;
	NETCFGInfo cfg_info[msnet_maxnum_iface+1];
	ms_u08  num_defaultroute;
}NETCARDInfo;
typedef struct{
	ms_u08 modelname[256];	//cpu model name
	ms_u32 cpucores;			//
	ms_u32 siblings;			//  threads
	ms_u32 clflushsize;			//  1    cache
	ms_u32 cachesize;			//  2    cache
#if defined OS_PLATFORM_ARM64 ||defined OS_PLATFORM_ARMV7L
	ms_u08 bogomips[32];
#endif
}CPUHWInfo;

typedef struct{
	MS_U64 rate;		//bps
	MS_U64 bytes;	
	MS_U64 packets;	
	MS_U64 errs;
	MS_U64 drop;	
	MS_U64 fifo;
	MS_U64 frame_colls;	
	MS_U64 compressed_carrier;
	MS_U64 multicast_compressed;	
}NETDATAInfo;

typedef struct{
	NETDATAInfo rx_netdata_info[msnet_maxnum_iface+1];
	NETDATAInfo tx_netdata_info[msnet_maxnum_iface+1];
	ms_u32 speed[msnet_maxnum_iface+1];
	ms_u08 duplex[msnet_maxnum_iface+1];
	ms_u08 autoneg[msnet_maxnum_iface+1];
	ms_bool is_linkup[msnet_maxnum_iface+1];
}NETInfo;


typedef struct{
	long num;
	float usage[mscfg_maxnum_cpu];			//cpu
	ms_byte temperature[mscfg_maxphysicsnum_cpu][128];
	ms_byte freq[mscfg_maxnum_cpu][128];
	ms_byte runMode[mscfg_maxnum_cpu][128];
	MS_U64 btime;
	MS_U64 procs_running;
	MS_U64 procs_blocked;
}CPUInfo;

typedef struct MOUNTInfo{
	char dev[128];
	char mntpoint[128];
	char mntinfo[128];
	ms_s64 dtotal;
	ms_s64 dused;
	ms_s64 dfree;
}MOUNTInfo;
typedef struct{
	char mountpoint_num;
	MOUNTInfo mount_info[mscfg_maxnum_partiton];
}DISKInfo;
typedef struct{
	ms_byte 	name[32];	
	ms_byte 	model[128];	
	ms_bool	flag_hotplug;
	ms_byte	sizeinfo[32];
	ms_byte 	serialno[64];	
}DISKHWInfo;

typedef struct{
	CPUHWInfo	cpuhw_info;
	NETCARDInfo	netcard_info;
	PCIDEVInfo	pcidevinfo;
	ms_byte		num_diskdev;
	DISKHWInfo	diskhwinfo[msnet_maxnum_diskdev];       
	ms_byte	dmidecode_info[maxlen_dmidecode_info];
	ms_byte	systemuuid[maxlen_systemuuid];	
	ms_byte	processorid[maxlen_processorid];	
	ms_byte 	blk_info_serialsda[maxlen_blkserial_info];	
}HARDWAREInfo;

typedef struct{
	ms_u08 is_connected_ethernet;
	CPUInfo	cpu_info;
	MEMInfo	mem_info;
	NETInfo	net_info;
	DISKInfo	disk_info;
}SYSPERFORMInfo;
typedef enum{
	ossys_linux		=0x0000,	
//param check 	
	ossys_debain,
	ossys_debain_ubuntu,
	ossys_debain_ubuntu1604,
	ossys_debain_ubuntu1804,
	ossys_debain_ubuntu2004,
	ossys_debain_ubuntu2204,
	ossys_debain_deepin,
	ossys_debain_uos20,
	ossys_rhel,
	ossys_rhel_centos,
	ossys_rhel_kylin,
	ossys_rhel_neokylin,
}OSSYSTEM;
typedef struct OSInfo{
	ms_u08 is_littleendian;
	ms_u08 is_supperuser;
	ms_u08 is_inDocker;
	ms_u08 sysname[256];		//Linux	
	ms_u08 nodename[256];	//msos
	ms_u08 release[256];		//4.4.0-53-generic
	ms_u08 version[256];		//Ubuntu 18.04.4 LTS
	ms_u08 machine[256];		//x86_64 
	ms_u08 server_starttime[256];
	struct rlimit stack_size;
	struct rlimit max_open_files;
	struct rlimit max_user_processes;
	struct rlimit time_cpu;
	struct rlimit data_seg;
	struct rlimit file_size;
	ms_u08 has_safenetdriver;

	ms_u08   route_default[512];
	ms_u08   dns1[16];
	ms_u08   dns2[16];
	OSSYSTEM ossystem;

	ms_byte aarchCheck[512];
	ms_byte aarchCheck_exinfo[512];
	ms_bool	flag_aarchCheckPass;
}OSInfo;

#ifndef MSPERFORMANCE_C
extern HARDWAREInfo hardware_info;
extern OSInfo  os_info;
extern SYSPERFORMInfo  sysperform_info;
extern FILE *msfp_netdev;

extern char 
	mspmc_api_init(void );
extern char 
	mspmc_api_run(SYSPERFORMInfo *sysperform_info,NETCARDInfo *pnetcard_info,void (*waring_func)(void),
		ms_bool flag_disable_checknet,ms_bool flag_disable_checkmem,ms_bool flag_disable_checkdisk,ms_bool flag_disable_checkcpu);
extern void 
	mspmc_api_deinit(void );
extern ms_void 
	mspmc_api_neteExternInfo_msg(ms_string ifacename,const char * func,ms_s32 line);
extern void 
	mspmc_api_checkEthernet(void);
extern char 
	mspmc_api_netInfo(NETCARDInfo *pnetcard_info);
extern void 
	mspmc_api_buildOSinfo(char * outstr);
extern char 
	mspmc_api_getDevHWInfo(char *device_basecode);
#else
char 
	mspmc_api_run(SYSPERFORMInfo *sysperform_info,NETCARDInfo *pnetcard_info,void (*waring_func)(void),
		ms_bool flag_disable_checknet,ms_bool flag_disable_checkmem,ms_bool flag_disable_checkdisk,ms_bool flag_disable_checkcpu);
char 
	mspmc_api_netInfo(NETCARDInfo *pnetcard_info);

#endif
#endif

